package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.GuardrailFaultCheckService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/15.
 */
@Controller
@RequestMapping("/rds_guardrailFaultCheck")
public class GuardrailFaultCheckController {
    @Resource
    private GuardrailFaultCheckService guardrailFaultCheckService;

    @RequestMapping(value = "/getGuardrailFaultCheck4DT")
    @ResponseBody
    public DTResponseDto getGuardrailFaultCheck4DT(DTRequestDto dtRequestDto, Integer actorId , Integer orgId) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = guardrailFaultCheckService.getGuardrailFaultCheck4DT(dtRequestDto,actorId, orgId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }



    @RequestMapping(value = "/guardrailFaultAudit")
    @ResponseBody
    public JsonMsgDto guardrailFaultAudit(Integer isPass, String feedback, Integer faultId, Integer userId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultCheckService.guardrailFaultAudit(isPass, feedback, faultId, userId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getGuardrailFaultCheckList4App")
    @ResponseBody
    public JsonMsgDto getGuardrailFaultCheckList4App(Integer orgId, String actorIds, Integer faultStatus, Integer count, Integer size) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultCheckService.getGuardrailFaultCheckList4App(orgId, actorIds, faultStatus, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getGuardrailInfo2Fault")
    @ResponseBody
    public JsonMsgDto getGuardrailInfo2Fault(Integer guardrailId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultCheckService.getGuardrailInfo2Fault(guardrailId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getGuardrailFaultInfo2Fault")
    @ResponseBody
    public JsonMsgDto getGuardrailFaultInfo2Fault(Integer guardrailId, Integer guardrailFaultId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultCheckService.getGuardrailFaultInfo2Fault(guardrailId, guardrailFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getGuardrailFaultReportList4App")
    @ResponseBody
    public JsonMsgDto getGuardrailFaultReportList4App(Integer orgId, String actorIds, Integer faultStatus, Integer count, Integer size)
            throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(guardrailFaultCheckService.getGuardrailFaultReportList4App(orgId,actorIds,faultStatus,count,size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }
}
